//
//  XMSHttpChannel.h
//  etionMisc
//
//  Created by wu jingxing on 12-11-21.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "RequestChannel.h"

typedef NS_ENUM(NSUInteger,XMSHTTPOperateResultType)
{
    XMSHTTPOperateResultTypeFinish=7,
    XMSHTTPOperateResultTypeFail=8,
    XMSHTTPOperateResultTypeTerminate=9,
    XMSHTTPOperateResultTypeRecvResponseError=10,
};

@class XMSHttpChannel;

@protocol XMSHttpChannelDelegate<NSObject>

-(void)HTTPOperateResult:(XMSHttpChannel*)http type:(XMSHTTPOperateResultType)type result:(NSInteger)nResult error:(NSError*)error;

@end

@interface XMSHttpChannel : CRequestChannel

@property(nonatomic,assign) id<XMSHttpChannelDelegate> delegate;
@property(nonatomic,readonly) NSMutableData* data;

-(id)initWithURLString:(NSString*)szUrl;

-(id)initWithURLRequest:(NSURLRequest*)urlrequest;

-(void)setHTTPHeaderFields:(NSDictionary*)dicHeader;

-(void)setHTTPMethod:(NSString*)szMethod;

-(void)setHTTPPutMethod;

-(void)setHTTPGetMethod;

-(void)setHTTPPostMethod;

-(void)setHTTPBody:(NSString*)szBody;

-(void)setHTTPDataBody:(NSData*)body;

-(BOOL)startRequest;

@end

@interface NSMutableDictionary (XMSHttpChannel)

-(void)setContentLengthValue:(NSString*)szValue;

-(void)setContentTypeValue:(NSString*)szValue;

@end

@interface XMSHttpChannel (TransferURL)

/**
 *  对URL进行转换处理
 *
 *  @param transferURL 需要处理URL的block
 */
+(void)operateNeedTransferURLBlock:(NSString*(^)(NSString *URL))transferURL;

@end
